﻿<%@ Page Title="QC SicoMill 635 Mess" Language="C#" MasterPageFile="~/TableMaster.master" AutoEventWireup="true" CodeFile="qcsicomill_635mess.aspx.cs" Inherits="Pages_qcsicomill_635mess" %>
<%@ Register Src="../UserControls/POTextBox.ascx" TagName="POTextBox" TagPrefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <style>
        @media only screen and (max-width: 760px), (min-device-width: 768px) and (max-device-width: 1024px) {

            .resTbl tr:nth-of-type(odd) {
                background-color: #CDE2FF;
            }

            .resTbl tr:nth-of-type(1) {
                display: none;
            }

            .resTbl td:nth-of-type(1):before {
                content: "Work Order #";
            }

            .resTbl td:nth-of-type(2):before {
                content: "Drum Number";
            }
            .resTbl td:nth-of-type(3):before {
                content: "Budgeted Qty";
            }
            .resTbl td:nth-of-type(4):before {
                content: "Actual Qty";
            }

            .resTbl td:nth-of-type(5):before {
                content: "Mess 635";
            }

            .resTbl td:nth-of-type(6):before {
                content: "Remark";
            }

            .resTbl td:nth-of-type(7):before {
                content: "Is Active";
            }

            .resTbl td:nth-of-type(8):before {
                content: "Created By";
            }

            .resTbl td:nth-of-type(9):before {
                content: "Created Date";
            }
        }

        
    </style>

    <script type="text/javascript">

        var ddlRM_Order_Number, ddlDrum_Number;

        $(document).ready(function () {
            ddlRM_Order_Number = $("#<%=ddlWork_Order_Number.ClientID%>");
            ddlDrum_Number = $("#<%=ddlDRUM_Number.ClientID%>");

            ddlRM_Order_Number.change(function () {
                getDrums();
            });
        });


        function save() {
            var Work_Order_Number = $('#MainContent_Add_ddlWork_Order_Number').val();
            var DRUM_Number = $('#MainContent_Add_ddlDRUM_Number').val();
            var Budgeted_Qty = $('#MainContent_Add_txtBudgeted_Qty').val();
            var Actual_Qty = $('#MainContent_Add_txtActual_Qty').val();
            var mess_635 = $('#MainContent_Add_txtmess_635').val();
            //var Remark = $('#MainContent_Add_txtRemark').val();

            if (Work_Order_Number == "0") {
                alert('Please Select Work Order Number');
                return;
            }
            if (DRUM_Number == "0") {
                alert('Please Select DRUM Number');
                return;
            }

            //if (Budgeted_Qty == "") {
            //    alert('Please enter Budgeted Qty');
            //    return;
            //}
            if (Actual_Qty == "") {
                alert('Please enter Actual Qty ');
                return;
            }
            if (mess_635 == "") {
                alert('Please enter mess 635');
                return;
            }
            if (Remark == "") {
                alert('Please enter Remark');
                return;
            }

            var inputs = ["MainContent_Add_ddlWork_Order_Number", "MainContent_Add_ddlDRUM_Number", "MainContent_Add_txtBudgeted_Qty", "MainContent_Add_txtActual_Qty", "MainContent_Add_txtmess_635", "MainContent_Add_txtRemark"];
            var fields = ["Work_Order_Number", "DRUM_NUMBER", "Budgeted_Qty", "Actual_Qty", "mess_635", "Remark"];
            var editurl = (window.location.search).split('=');
            var Id = editurl[editurl.length - 1];
            if (Id == "") {
                saveData('mytable', fields, inputs, 'Services.aspx/save_635mess');
            } else {
                updateData('mytable', fields, inputs, 'Services.aspx/update_635mess', Id, "MESS635_ID");
            }
        }

        function getDrums() {
            if (window.location.search != "") {
                ddlRM_Order_Number = $("#<%=ddlWork_Order_Number.ClientID%>");

                ddlDrum_Number = $("#<%=ddlDRUM_Number.ClientID%>");
            }

            ddlDrum_Number.empty();
            ddlDrum_Number.append("<option>Loading...</option>");

            $.ajax({
                type: "POST",
                url: "http://" + window.location.host + "/Inventory/Services/Services.aspx/getDrumNumberFor635Mess",
                data: "{'WorkOrderNumber': '" + ddlRM_Order_Number.val() + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {

                    ddlDrum_Number.empty();

                    if (data.d.length == 0)
                        return;

                    ddlDrum_Number.append("<option value='0'>--Select DRUM--</option>");
                    $.each(data, function (i, item) {
                        $.each(item, function (j, ddlItem) {
                            ddlDrum_Number.append('<option  value="' + ddlItem.DRUM_NUMBER + '"> ' + ddlItem.DRUM_NUMBER + '</option>');
                        });
                        $('#MainContent_Add_ddlDRUM_Number').val($('#MainContent_Add_ddlDRUM_Number').attr('selectedval'));
                    });
                }
            });
        }

        function updateDropDownValue() {

        }
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Add" runat="Server">


    <asp:Panel ID="pnlAdd" runat="server" CssClass="qcbg">

        <table id="mytable" cellpadding="0" cellspacing="0" >

            <tr>
                <td style="width: 170px">
                    <asp:Label ID="lblWork_Order_Number" runat="server" AssociatedControlID="ddlWork_Order_Number" Text="Work Order #:"></asp:Label>
                </td>
                <td style="width: 112px">
                    <asp:Label ID="lblDRUM_NUMBER" runat="server" AssociatedControlID="ddlDRUM_Number" Text="Drum Number:"></asp:Label>
                </td>
                 <td>
                    <asp:Label ID="lblBudgeted_Qty" runat="server" AssociatedControlID="txtBudgeted_Qty" Text="Budgeted Qty:"></asp:Label>
                </td>
                 <td>
                    <asp:Label ID="lblActual_Qty" runat="server" AssociatedControlID="txtActual_Qty" Text="Actual Qty:"></asp:Label>
                </td>
                <td style="width: 70px">
                    <asp:Label ID="lblmess_635" runat="server" AssociatedControlID="txtmess_635" Text="-635 Mess:"></asp:Label>
                </td>
                <td style="width: 170px">
                    <asp:Label ID="lblRemark" runat="server" AssociatedControlID="txtRemark" Text="Remark:"></asp:Label>
                </td>
                <td></td>
            </tr>

            <tr>
                <td style="width: 170px">
                    <asp:DropDownList ID="ddlWork_Order_Number" runat="server" DataSourceID="DS_Work_Order_Num" DataTextField="Work_Order_Number" DataValueField="Work_Order_Number" OnDataBound="ddlWork_Order_Number_DataBound"></asp:DropDownList>
                    <asp:ObjectDataSource ID="DS_Work_Order_Num" runat="server" SelectMethod="ddlWorkOrderFor635_Mess" TypeName="DAL_tbl_qcsicomill_ssa"></asp:ObjectDataSource>
                </td>
                <td style="width: 112px">
                    <%--<asp:TextBox ID="txtDRUM_NUMBER" runat="server" Width="94px"></asp:TextBox>--%>
                    <asp:DropDownList ID="ddlDRUM_Number" runat="server" Width="103px"></asp:DropDownList>
                </td>
                <td >
                    <asp:TextBox ID="txtBudgeted_Qty" runat="server" Validate="Number"></asp:TextBox>
                </td>
                <td >
                    <asp:TextBox ID="txtActual_Qty" runat="server" Validate="Number" ></asp:TextBox>
                </td>
                <td style="width: 70px">
                    <asp:TextBox ID="txtmess_635" runat="server" Width="66px"></asp:TextBox>
                </td>
                <td style="width: 170px">
                    <asp:TextBox ID="txtRemark" runat="server"></asp:TextBox>
                </td>
                <td>
                    <button type="button" class="btn btn-default btn-xs" onclick="removeRow(this);"><span class="glyphicon glyphicon-remove"></span></button>
                </td>
            </tr>

        </table>
        <button type="button" class="btn btn-default btn-xs" onclick="addRow('mytable');"><span class="glyphicon glyphicon-plus"></span>Add Row</button>
        
        <br />
        
        <br />
        
        <input type="button" value="Save" style="width:90px" class="btn btn-success" onclick="save();" />
        <%--<asp:Button ID="btnSave" runat="server" CssClass="btn btn-success" OnClick="btnSave_Click" Text="Save" Width="90px" />--%>
        <asp:Button ID="btnCancel" runat="server" CssClass="btn btn-danger" OnClick="btnCancel_Click" Text="Cancel" Width="90px" />
         
        
    </asp:Panel>

</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Grid" runat="Server">
    <asp:Panel ID="pnlList" runat="server">
        <asp:GridView ID="gridClients" runat="server" AutoGenerateColumns="False" CssClass="resTbl" DataSourceID="DS_tbl_qcsicomill_635mess">
            <Columns>
                <asp:BoundField DataField="Work_Order_Number" HeaderText="Work Order #" SortExpression="Work_Order_Number" />
                <asp:BoundField DataField="DRUM_NUMBER" HeaderText="Drum Number" SortExpression="DRUM_NUMBER" />
                <asp:BoundField DataField="Budgeted_Qty" HeaderText="Budgeted Qty" SortExpression="Budgeted_Qty" />
                <asp:BoundField DataField="Actual_Qty" HeaderText="Actual Qty" SortExpression="Actual_Qty" />
                <asp:BoundField DataField="mess_635" HeaderText="Mess 635" SortExpression="mess_635" />
                <asp:BoundField DataField="Remark" HeaderText="Remark" SortExpression="Remark" />
                <asp:BoundField DataField="IS_ACTIVE" HeaderText="Is Active" SortExpression="IS_ACTIVE" />
                <asp:BoundField DataField="CREATED_BY" HeaderText="Created By" SortExpression="CREATED_BY" />
                <asp:BoundField DataField="CREATED_DATE" HeaderText="Created Date" SortExpression="CREATED_DATE" DataFormatString="{0:yyMMdd}"/>

                <asp:TemplateField HeaderText="Edit">
                    <ItemTemplate>
                        <asp:LinkButton ID="linkEdit" runat="server" Text="Edit" CommandArgument='<%# Eval("MESS635_ID") %>' OnClick="linkEdit_Click"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Delete">
                    <ItemTemplate>
                        <asp:LinkButton ID="linkDelete" CommandName="delete" runat="server" Text="Delete" OnClientClick="javascript:return confirm('Are you sure you want to delete this record?');" CommandArgument='<%# Eval("MESS635_ID") %>' OnClick="linkDelete_Click"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <asp:ObjectDataSource ID="DS_tbl_qcsicomill_635mess" runat="server" SelectMethod="selectAllForGrid" DeleteMethod="delete" InsertMethod="insert" UpdateMethod="update" TypeName="DAL_tbl_qcsicomill_635mess">
            <DeleteParameters>
                <asp:Parameter Name="MESS635_ID" Type="String" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="Work_Order_Number" Type="String" />
                <asp:Parameter Name="DRUM_NUMBER" Type="String" />
                <asp:Parameter Name="Budgeted_Qty" Type="Int32" />
                <asp:Parameter Name="Actual_Qty" Type="Int32" />
                <asp:Parameter Name="mess_635" Type="String" />
                <asp:Parameter Name="Remark" Type="String" />
                <asp:Parameter Name="IS_ACTIVE" Type="Boolean" />
                <asp:Parameter Name="CREATED_BY" Type="String" />
                <asp:Parameter Name="CREATED_DATE" Type="DateTime" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="Work_Order_Number" Type="String" />
                <asp:Parameter Name="DRUM_NUMBER" Type="String" />
                <asp:Parameter Name="Budgeted_Qty" Type="Int32" />
                <asp:Parameter Name="Actual_Qty" Type="Int32" />
                <asp:Parameter Name="mess_635" Type="String" />
                <asp:Parameter Name="Remark" Type="String" />
                <asp:Parameter Name="IS_ACTIVE" Type="Boolean" />
                <asp:Parameter Name="UPDATED_BY" Type="String" />
                <asp:Parameter Name="UPDATED_DATE" Type="DateTime" />
            </UpdateParameters>
        </asp:ObjectDataSource>
    </asp:Panel>
</asp:Content>

